<?php

namespace App\Admin\Http\Requests;


class AdRequest extends Request
{
  /**
   * Determine if the user is authorized to make this request.
   *
   * @return bool
   */
  public function authorize()
  {
    return true;
  }

  /**
   * Get the validation rules that apply to the request.
   *
   * @return array
   */
  public function rules()
  {
    return [
        'name' => 'required|max:100',
        'position' => 'required|max:50',
        'image' => ($this->route('ads') && !$this->file('image') ? '':'required|image'),
        'link' => 'required|max:200',
        'description' => 'max:200',
        'sort' => 'required|integer',
    ];
  }

  public function attributes()
  {
    return [
      'name' => '名称',
      'image' => '图片',
      'position' => '广告位',
      'link' => '链接',
      'description' => '描述',
      'sort' => '排序',
    ];
  }
}
